#pragma once

/*
 * File - ros_pointcloud_publisher.h
 *
 * This file is part of the Inuitive SDK
 *
 * Copyright (C) 2014-2020 Inuitive All Rights Reserved
 *
 */

#include "ros_publisher.h"

#include "PointCloudStream.h"

/**
 * \cond INTERNAL
 */

#include "config.h"

/**
 * \endcond
 */

/**
 * \file ros_pointcloud_publisher.h
 *
 * \brief PointCloud publisher
 */

namespace __INUROS__NAMESPACE__
{
    /**
     * \brief ROS PointCloud publisher
     */
    class CRosPointcloudPublisher : public CRosPublisher
    {
        ros::Publisher publisher;

        void FrameCallback(std::shared_ptr<InuDev::CPointCloudStream> iStream, std::shared_ptr<const InuDev::CPointCloudFrame> iFrame, InuDev::CInuError iError);
        InuDev::CInuError RegisterCallback();
        InuDev::CInuError UnregisterCallback();

        static std::vector<const char*> fieldNames;

    protected:

        virtual InuDev::CInuError InitStream() override;
        virtual InuDev::CInuError StartStream() override;

    public:

        virtual int GetNumSubscribers() override;

        /**
         * \brief CRosPointcloudPublisher
         *
         * CRosPointcloudPublisher constructor
         */
        CRosPointcloudPublisher(ros::NodeHandle& _node, std::shared_ptr<image_transport::ImageTransport> _image_transport, CRosSensor* _rosSensor, std::string iTopicName = "sensor/PointCloud2");

    private:
        /**
         * \brief RGB ChannelID
         *
         * Channel ID as recieved from InuRosParams.xml : -1 is default
         */
        int mParamsChannelID;

        /**
         * \brief RGB OutputFormat
         *
         * Output format: 0 is default
         */
        int mOutputFormat;
        
        /**
         * \brief Convert PointCloud Short to Float
         *
         * "true" is default
         */
        bool mConvertPointCloudShortToFloat;

        /**
         * \brief mPointCloudFrameID - Used for multiple sensors
         */
        std::string mPointCloudFrameID;        

    };
}

